/**
 * @fileOverview
 * @author iNahoo
 * @since 2019/11/12.
 */

async function sleep(ms) {
    return new Promise(r => {
        setTimeout(r, ms);
    })
}

/**
 * @param f
 * @return {Promise.<*>}
 */
async function run(f) {
    return f();
}

async function loop(i, fn) {
    let _i = 0;
    do {
        _i++;
        await fn(_i);
    } while (_i < i);
}


module.exports = {
    sleep,
    run,
    loop,
};

